import org.springframework.ai.document.Document;
import org.sz.RedisDocumentReader;
import org.sz.RedisResource;

import java.util.List;

public class DocumentReaderDemo {
    public static void main(String[] args) {
        RedisResource redisResource = new RedisResource("localhost", 6379, "*");
        redisResource.setMaxConnections(10);

        try (RedisDocumentReader reader = new RedisDocumentReader(redisResource)) {
            // 同步读取
            List<Document> documents = reader.get();

            // 流式处理
            reader.streamDocuments(doc -> {
                System.out.println("Redis Key: " + doc.getMetadata().get("key"));
            });
        }
    }
}